
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/*
ID: huangmingbo
LANG: JAVA
TASK: combo
 */
public class combo {
    public static void main(String[] args) throws IOException {
        try (
                BufferedReader reader = new BufferedReader(new InputStreamReader(combo.class.getResourceAsStream(combo.class.getSimpleName() + ".in")));
                PrintWriter writer = new PrintWriter(new PrintWriter(combo.class.getSimpleName() + ".out"));
        ) {

            int N = Integer.parseInt(reader.readLine());
            StringTokenizer stringTokenizer = new StringTokenizer(reader.readLine());
            int[] arr1 = new int[]{Integer.parseInt(stringTokenizer.nextToken()), Integer.parseInt(stringTokenizer.nextToken()), Integer.parseInt(stringTokenizer.nextToken())};
            stringTokenizer = new StringTokenizer(reader.readLine());
            int[] arr2 = new int[]{Integer.parseInt(stringTokenizer.nextToken()), Integer.parseInt(stringTokenizer.nextToken()), Integer.parseInt(stringTokenizer.nextToken())};


            int count1 = getCount(N);

            int intersectionCount1 = getIntersect(arr1[0], arr2[0], N);
            int intersectionCount2 = getIntersect(arr1[1], arr2[1], N);
            int intersectionCount3 = getIntersect(arr1[2], arr2[2], N);

            writer.println(count1*2 - intersectionCount1 * intersectionCount2 * intersectionCount3);
        }

    }

    private static int getIntersect(int i, int j, int n) {
        if (n <= 4) {
            return n;
        }

        int count = 0;
        for (int i1 = 0; i1 < n; i1++) {
            if ((Math.abs(i-i1) <= 2 || Math.abs(i-i1)>= n-2) &&
                    (Math.abs(j-i1) <= 2 || Math.abs(j-i1)>= n-2)) {
                count++;
            }
        }


        return count;
    }

    private static int getCount(int n) {
        if (n <= 4) {
            return n * n * n;
        }

        return 5 * 5 * 5;
    }
}
